Notice = {
	getNotificationsUrl : "/skyline/notice/list.html",
	getNotifications : function() {
		var url = this.getNotificationsUrl;
		var data = null;
		$.ajax({
			url : url,
			data : data,
			type : "GET",
			dataType : "json",
			contentType : "application/x-www-form-urlencoded; charset=utf-8",
			success : function(msg) {
				if (msg != null && msg.length > 0) {
					var innerHTML = "";
					var notificationsDiv = document
							.getElementById("notifications");
					innerHTML += "共" + msg.length + "条通知:<br>";
					for ( var i = 0; i < msg.length; i++) {
						var notification = msg[i];
						innerHTML += Notice.getNotification(notification)
								+ "<br>";
					}
					notificationsDiv.innerHTML = innerHTML;
				}
			}
		});
	},
	viewNotification:function(notificationId){
		
	},
	getNotification : function(notification) {
		var notiStr = "<div id='notification"+notification.id+"'>";
		notiStr += "<a target='_blank' href='" + notification.notifierId + "'>"
				+ notification.notifierNickname + "</a>";
		if (notification.secondNotifierId
				&& notification.secondNotifierId != '') {
			notiStr += "与<a target='_blank' href='" + notification.secondNotifierId + "'>"
					+ notification.secondNotifierNickname + "</a>等";
		}
		if (notification.type == 'ARTICLE_COMMENT') {
			notiStr += "在您的日志<a target='_blank' href='" + SKYLINE_VIEWNOTIFICATION
					+ notification.id + ".html'>" + notification.resourceTitle
					+ "</a>回复了您。";
		} else if (notification.type == 'PHOTO_COMMENT') {
			notiStr += "在您的照片<a target='_blank' href='" + SKYLINE_VIEWNOTIFICATION
					+ notification.id + ".html'>" + notification.resourceTitle
					+ "</a>回复了您。";
		} else if (notification.type == 'ALBUM_COMMENT') {
			notiStr += "在您的相册<a target='_blank' href='" + SKYLINE_VIEWNOTIFICATION
					+ notification.id + ".html'>" + notification.resourceTitle
					+ "</a>回复了您。";
		} else if (notification.type == 'ATTENTION') {
			notiStr += "观注您。";
		} else if (notification.type == 'SHORTMESSAGE_COMMENT') {
			notiStr += "在您的<a target='_blank' href='" + SKYLINE_VIEWNOTIFICATION
					+ notification.id + ".html'>" + notification.resourceTitle
					+ "</a>回复了您。";
		} else if (notification.type == 'INVITATION') {
			notiStr += " 给您发来  <a target='_blank' href='" + SKYLINE_VIEWNOTIFICATION
					+ notification.id + ".html'>" + notification.resourceTitle
					+ "</a>";
		}
		notiStr+="</div>";
		return notiStr;
	},
	initial : function() {
		Notice.getNotifications();
		newNotificationTimmer = setInterval("Notice.getNotifications()", 120000);
	}
};
